﻿using System;
using System.Diagnostics;

namespace SimpleCalculator
{
    public class Calc
    {
        public long? Result { get; private set; }

        public Calc()
        {
            Result = null;
        }

        public byte ProcessCalculations(char operation, int operand1, int operand2)
        {
            byte fResult = 0;
            switch (operation)
            {
                case '+':
                    {
                        Result = (long)operand1 + (long)operand2;
                        break;
                    }
                case '-':
                    {
                        Result = (long)operand1 - (long)operand2;
                        break;
                    }
                case '/':
                    {
                        try
                        {
                            Result = (long)operand1 / (long)operand2;
                        }
                        catch (DivideByZeroException bze)
                        {
                            fResult = 1;
                            Result = null;
                            Trace.WriteLine(bze.Message, "error");
                        }
                        break;
                    }
                case '*':
                    {
                        Result = (long)operand1 * (long)operand2;
                        break;
                    }
                default:
                    {
                        fResult = 2;
                        Result = null;
                        break;
                    }
            }
            return fResult;
        }

    }
}
